function[] = thresholdValidation(classNames)
% validates the results of the threshold classification algorithm
%
%   INPUT
%   classNames..a cell array containing the class names for the validation

    correct = 0;
    count = 0;
    errorPics = '';
    
    %file for features list
    f_features = fopen('features.csv', 'wt');
    fprintf(f_features,'image,aspect ratio,formfactor,compactness,id\n');
    
    nr = 1;
    for i = 1 : size(classNames, 1)
        pictures = loadPictures(classNames{i});
        count = count + size(pictures, 1);
        for j = 1 : size(pictures, 1)
            features = calculateFeatures(pictures{j});
            
            %write features to file, for overview
            fprintf(f_features,strcat(classNames{i},num2str(j),',',num2str(features(1)),',',num2str(features(2)),',',num2str(features(3)),',',num2str(nr),'\n'));
            nr = nr + 1;
            
            % compare threshold classification result with ground truth
            if strcmp(thresholdClassification(features), classNames{i})
                correct = correct + 1;
            else
                errorPics = [errorPics ' ' num2str(j)];
            end
        end
    end
    
    %close file
    fclose(f_features);
    
    disp([num2str(correct) ' / ' num2str(count) ' misclassified pictures (id):' errorPics]);
end
